package com.gzcc.repository;

import com.gzcc.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description: 用户数据库查询操作
 * @Author: Mr.Zhong
 * @Date: 2018/6/13
 */
@Repository
public interface UserRepository extends JpaRepository<User, Integer> {


    /**
     * 描述: 通过用户名和密码查询用户
     *
     * @param name
     * @param password
     * @return User
     * @Author: Mr.Zhong
     * @Date: 2018/6/14
     */
    User findByNameAndPassword(String name, String password);

    /**
     * 描述: 通过用户名查询用户
     *
     * @param name
     * @return User
     * @Author: Mr.Zhong
     * @Date: 2018/6/14
     */
    User findByName(String name);

    /**
     * @param name 用户名
     * @return list
     */
    @Query(value = "select u from User u where u.name like %?1%")
    List<User> findByKey(String name);

}
